
import $ from 'jquery';
export function MP(ak) {

  return new Promise(function (resolve, reject) { 
  	let src_ = 'http://api.map.baidu.com/getscript?'
    
    
//  for(let i=0;i<$('script').length;i++){
//  	console.log($($('script')[i]).attr('src'))
//  	
//  	let src = $($('script')[i]).attr('src');
//  	if(src.indexOf(src_)>0){
//  		resolve(BMap)
//  		return;
//  	}
//  }
    
    var script = document.createElement("script");  
    script.type = "text/javascript";  
    script.src = "http://api.map.baidu.com/api?v=2.0&ak=lAW6GP6dEoDcXRBkujwYLu5h9Fncmd00"+"&callback=init";  
    script.onerror = reject;  
    document.head.appendChild(script);  
    setTimeout(()=>{
    	resolve(BMap)
    },500);    
  })  
} 